package com.cyt.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.cyt.dao.impl.SPFeiLeiDaoImpl;
import com.cyt.dao.impl.ShangPingSouSuoDaoImpl;
import com.cyt.dao.impl.ShangPingXXDaoImpl;
import com.cyt.entity.SPFeiLei;
import com.cyt.entity.ShangPingXX;

//产品分类  产品细致性分类 即点击系列 出来该系列所有产品
public class ProductsServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//产品分类
		HttpSession session =request.getSession();
		 int shangPingId =Integer.parseInt(request.getParameter("categoryId"));
		SPFeiLeiDaoImpl sDao= new SPFeiLeiDaoImpl();//创建对象
	    List <SPFeiLei> list=sDao.getSPFeiLei();//调用方法获得用户集合
	   request.setAttribute("sp", list);//将数据存入request中
	   
	   
	   //商品上面的单个显示分类
	   int cPFLId =Integer.parseInt(request.getParameter("categoryId"));
	   SPFeiLeiDaoImpl slDao= new SPFeiLeiDaoImpl();//创建对象
	    List <SPFeiLei> spFLlist=slDao.getSPFeiLeiTwo(cPFLId);//调用方法获得用户集合
	   request.setAttribute("spl", spFLlist);//将数据存入request中
	   
	   //根据产品分类id查询对应产品
	   //接受前台传回的参数
	   int fengLeiId =Integer.parseInt(request.getParameter("categoryId"));
	   ShangPingXXDaoImpl spDao=new ShangPingXXDaoImpl();
	   List <ShangPingXX> sPList =  spDao.getShangPingXX(fengLeiId);
	   request.setAttribute("Shang", sPList);//将数据存入request中
	   session.setAttribute("Shang", sPList);
	  
	   
	  

		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}
  
	  
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
